import { createRouter, createWebHistory, createWebHashHistory} from 'vue-router'
import PageView from '@/views/PageView.vue'
import HomeView from '@/views/Home/HomeView.vue'

//createRouter创建router实例
// 1.History模式 createWebHistory(import.meta.env.BASE_URL)  地址不带#
// 2.hash模式 createWebHashHistory(import.meta.env.BASE_URL)  地址带#
//import.meta.env.BASE_URL  vite中的环境变量  ---> vite.config.js 中的base配置项
const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: '/',
      name: 'page',
      component: PageView,
      children:[
        {
          path: '/home',
          name: 'home',
          component: HomeView
        },
      ],
      redirect:'/home'
    },

    {
      path: '/index',
      name: 'index',
      component: () => import('@/views/Index/indexView.vue')
    },
    {
      path: '/login',
      name: 'login',
      component: () => import('@/views/Login/loginView.vue')
    }
  ]
})

export default router
